using System;
using ScenarioFramework.WorkflowEngine.DataModel;

namespace ScenarioFramework.WorkflowEngine.DataModel.WorkflowProcesses
{
	public class XMLReport : bOSdotNET.XML.Data.XMLObject 
	{
		public const string MAIN_NODE				= "Report";

		private const string DATE_ATTRIBUTE		= "Date";

		private String sDate;
		private String sText;

		public XMLReport()
		{
			this.Init();
		}

		public XMLReport(System.Xml.XmlNode node)
		{
			this.Parse(node);
		}

		/** PROPERTIES **/
		public string Date 
		{
			get { return sDate; }
			set { sDate = value; }
		}

		public string Text 
		{
			get { return sText; }
			set { sText = value; }
		}

		override public void Init()
		{
			sDate= string.Empty;
			sText= string.Empty;
		}

		override public void Parse(System.Xml.XmlNode node2Parse)
		{
			this.Init();

			System.Xml.XmlNode node;

			/** find the attributes situated on the root tag **/
			for ( int i=0; i<node2Parse.Attributes.Count;i++)
			{
				node = node2Parse.Attributes.Item(i);
				switch ( node.Name ) 
				{
					case XMLReport.DATE_ATTRIBUTE:
						sDate = node.InnerText;
						break;
				}
			}
			sText = node2Parse.InnerText;
		}

		override public bOSdotNET.XML.XMLNode GetXMLNode()
		{
			bOSdotNET.XML.XMLNode xmlNode = new bOSdotNET.XML.XMLNode(XMLReport.MAIN_NODE, sText);
			xmlNode.AddAttribute ( new bOSdotNET.XML.XMLAttribute (XMLReport.DATE_ATTRIBUTE, sDate) );

			return xmlNode;
		}
	}
}
